package com.szdvte.news.action.service;

import java.util.List;

import org.apache.struts2.ServletActionContext;

import com.szdvte.news.bean.NewsType;
import com.szdvte.news.service.INewsTypeService;

public class NewsTypeAction extends BaseAction{
	private NewsType newsType;
	private INewsTypeService newsTypeService;
	private List<NewsType> list;
	public String add(){
		this.setFlag(1);
	    if(newsTypeService.add(newsType)){
	    	this.setFlag(2);
	    }else{
	    	this.setFlag(3);
	    }
		
		return "add";
	}
	public String update(){
		this.setFlag(1);
	    if(newsTypeService.update(newsType)){
	    	this.setFlag(2);
	    }else{
	    	this.setFlag(3);
	    }
		return "load";
	}
	public String load(){
		newsType = newsTypeService.load(newsType);
		return "load";
	}
	public String delete(){
		this.setFlag(1);
	    if(newsTypeService.delete(newsType)){
	    	this.setFlag(2);
	    }else{
	    	this.setFlag(3);
	    }
	    show();
		return "newsType";
	}
	public String select(){
		show();
		return "newsType";
	}
	private void show(){
		list = newsTypeService.select();
		ServletActionContext.getRequest().getSession().setAttribute("newTypeList", list);
	}
	public NewsType getNewsType() {
		return newsType;
	}
	public void setNewsType(NewsType newsType) {
		this.newsType = newsType;
	}
	public INewsTypeService getNewsTypeService() {
		return newsTypeService;
	}
	public void setNewsTypeService(INewsTypeService newsTypeService) {
		this.newsTypeService = newsTypeService;
	}
	public List<NewsType> getList() {
		return list;
	}
	public void setList(List<NewsType> list) {
		this.list = list;
	}
}
